using System;
using System.Collections.Generic;
using System.Text;

namespace CropperPlugins
{
    class TimeSettings : IDisposable
    {
        private long? secTime;
        private bool? recordActiveWindow;

        public bool RecordActiveWindowText
        {
            get
            {
                if (recordActiveWindow == null)
                {
                    try
                    {
                        string strSaved = global::Cropper.TimeCapture.Properties.Settings.Default.SaveCaption;
                        recordActiveWindow = (strSaved != "0");
                    }
                    catch (Exception)
                    {
                        recordActiveWindow = true;
                    }
                }
                return recordActiveWindow.Value;
            }
            set
            {



                recordActiveWindow = value;
            }
        }



        public long SecTime
        {
            get
            {
                if (secTime == null)
                {
                    try
                    {
                        string strSaved = global::Cropper.TimeCapture.Properties.Settings.Default.Seconds;
                        secTime = long.Parse(strSaved);
                    }
                    catch (Exception)
                    {
                        secTime = 30;
                    }
                }

                return secTime.Value;
            }
            set
            {

                secTime = value;
            }
        }

        public void Save()
        {
            try
            {
                

                global::Cropper.TimeCapture.Properties.Settings.Default.Seconds = "" + SecTime;

                if (RecordActiveWindowText)
                    global::Cropper.TimeCapture.Properties.Settings.Default.SaveCaption = "1";
                else
                    global::Cropper.TimeCapture.Properties.Settings.Default.SaveCaption = "0";

                global::Cropper.TimeCapture.Properties.Settings.Default.Save();
            }
            catch (Exception)
            {

            }

        }
        #region IDisposable Members


        public void Dispose()
        {

        }

        #endregion


    }
}
